Play sound on menu items on hover [migrated]
Posted
by
Mahalia Samuels
on Programmers
See other posts from Programmers
or by Mahalia Samuels
Published on 2012-10-13T21:04:02Z
Indexed on
2012/10/13
21:52 UTC
Read the original article
Hit count: 124
How can I go about making a sound clip play when an element is hovered over?
I'm using the latest Wordpress, and the parent theme I am using gives me an option to paste scripts which it will embed to the <head>
section.
Is there a script which I can just add to my <head>
that will play the sound when the cursor moves over my menu item class .menu li
?
I spent several hours trying to figure this out the other day with no avail. I've done this before in a simple HTML website:
<head>
<script language="javascript" type="text/javascript">
function playSound(soundfile) {
document.getElementById("dummy").innerHTML=
"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
</script>
</head>
<li><a href="index.html" onmouseover="playSound('lib/hover.mp3');" onclick="playSound('lib/click.mp3');"><span>Home</span></a></li>
Not sure how to deploy this on Wordpress though.
© Programmers or respective owner